Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LCM to DIFFUSERS_TASKS_TO_MODEL_LOADERS #1762

Closed
wants to merge 2 commits into from

Conversation

l-bat
Copy link

@l-bat l-bat commented Mar 21, 2024

What does this PR do?

Relates to huggingface/optimum-intel#618

  • Fix stable-diffusion-xl mapping
  • Support latent-consistency task

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@AlexKoff88
Copy link
Contributor

@echarlaix, can you please take a look? This is required for https://github.com/huggingface/optimum-intel/pull/618/files

Comment on lines -192 to +191
"stable-diffusion-xl": "StableDiffusionXLImg2ImgPipeline",
"stable-diffusion-xl": "StableDiffusionXLPipeline",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_optional_components was introduced in diffusers v0.22.0 https://github.com/huggingface/diffusers/blob/v0.22.0/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py#L144, so we would need to upgrade DIFFUSERS_MINIMUM_VERSION as well to avoid any potential issue when loading a SDXL model (which don't have optional components)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"stable-diffusion-xl-refiner": "StableDiffusionXLImg2ImgPipeline",
"latent-consistency": "LatentConsistencyModelPipeline",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you extend on why this is needed ? To my knowledge this shouldn't be needed (both pipelines can be correctly loaded using the current _DIFFUSERS_TASKS_TO_MODEL_LOADERS

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also at the moment inferred task for diffusers models will either be "stable-diffusion-xl" or "stable-diffusion"

inferred_task_name = "stable-diffusion-xl" if "StableDiffusionXL" in class_name else "stable-diffusion"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary to correctly determine the model class from task. Hybrid quantization supports the stable-diffusion-xl task, but doesn't support the stable-diffusion-xl-refiner. Without these changes, it is not possible to apply hybrid quantization via CLI.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that we need it in the TaskManager, from what I see it's only needed to get the class to load the model in the optimum-intel CLI for diffusers models, could we move it in optimum-intel directly instead ? We could get this information by combining the task (text-to-image, image-to-image, inpaint, ..) and the architecture (SD, SDXL, LCMs, ..) using the model's config

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting to remove only the latent-consistency from _DIFFUSERS_TASKS_TO_MODEL_LOADERS?

As far as I understand, there are no text-to-image, image-to-image, inpaint,.. tasks in optimum. Should I create these tasks only for optimum-intel instead of stable-diffusion, stable-diffusion-xl, stable-diffusion-xl-refiner and latent-consistency? In this case, we cann't use TasksManager.infer_task_from_model for diffusion models.

@l-bat l-bat force-pushed the lt/extend_diffusers_tasks branch from 3058da7 to f36e61e Compare April 3, 2024 13:04
@l-bat l-bat requested a review from echarlaix April 3, 2024 13:05
@l-bat l-bat closed this Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants